package java_learn.java_jinjie.ThreadSafe;

/**
 * @Author: 李浩然
 * @Date: 2021/2/24 12:47 下午
 */
public class RunnableTest implements Runnable {
    private static int ticket = 1;

    @Override
    public void run() {
        while (ticket <= 100) {
            synchronized (this.getClass()) {
                if (ticket <= 100) {
                    System.out.println("正在卖第" + ticket++ + "张票");
                }
            }
        }
    }
}
